package com.java8.dome1;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by Wanghk on 2019/6/25.
 */
public class FilterApple {
    public List<Apple> findGreenApple(List<Apple> apples){
        List<Apple> list = new ArrayList<>();
        for (Apple apple : apples) {
            if("green".equals(apple.getColor())){
                list.add(apple);
            }
        }
        return list;
    }

    @Test
    public void test() {
       /* List<Apple> apples = Arrays.asList(new Apple("green", 1L), new Apple("red", 2L));
        List<Apple> greenApple = findGreenApple(apples);
        assert greenApple.size()==2;
        System.out.println(greenApple);*/
        //断言1结果为true，则继续往下执行
        assert true;
        System.out.println("断言1没有问题，Go！");

        System.out.println("\n-----------------\n");

        //断言2结果为false,程序终止
        assert false : "断言失败，此表达式的信息将会在抛出异常的时候输出！";
        System.out.println("断言2没有问题，Go！");

    }
}
